//package com.yupi.springbootinit.config;
//
//import org.springframework.amqp.core.Binding;
//import org.springframework.amqp.core.BindingBuilder;
//import org.springframework.amqp.core.CustomExchange;
//import org.springframework.amqp.core.DirectExchange;
//import org.springframework.amqp.core.Queue;
//import org.springframework.amqp.core.QueueBuilder;
//import org.springframework.amqp.core.Exchange;
//import org.springframework.amqp.rabbit.annotation.EnableRabbit;
//import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
//import org.springframework.amqp.support.converter.MessageConverter;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * RabbitMQ delayed exchange + DLQ 基础配置
// */
//@Configuration
//// @EnableRabbit  // RabbitMQ 已暂停使用
//public class RabbitMqConfig {
//
//    // Exchanges
//    public static final String EXCHANGE_DELAYED = "dios.events.delayed"; // x-delayed-message (topic)
//    public static final String EXCHANGE_DLX = "dios.events.dlq";         // DLQ direct exchange
//
//    // Queues
//    public static final String QUEUE_MSG_IMMEDIATE = "msg.immediate";
//    public static final String QUEUE_REMINDER_UNCLAIMED = "reminder.unclaimed";
//    public static final String QUEUE_REMINDER_OVERDUE = "reminder.overdue";
//    public static final String QUEUE_DLQ = "dlq.msg";
//    public static final String QUEUE_QUALITY_FINAL_READY = "quality.final.inspection.ready";
//    public static final String QUEUE_PMC_BATCH_SUBMITTED = "pmc.batch.submitted";
//
//    // Routing keys
//    public static final String RK_ORDER_CREATED = "order.created";
//    public static final String RK_TASK_CREATED = "task.created";
//    public static final String RK_REMINDER_UNCLAIMED = "reminder.unclaimed";
//    public static final String RK_REMINDER_OVERDUE = "reminder.overdue";
//    public static final String RK_DLQ = "dlq.msg";
//    public static final String RK_QUALITY_FINAL_READY = "quality.final.inspection.ready";
//    public static final String RK_PMC_BATCH_SUBMITTED = "pmc.batch.submitted";
//
//    // message converter (JSON)
//    @Bean
//    public MessageConverter jacksonMessageConverter() {
//        return new Jackson2JsonMessageConverter();
//    }
//
//    // delayed exchange using plugin x-delayed-message, inner type topic
//    @Bean
//    public CustomExchange delayedExchange() {
//        Map<String, Object> args = new HashMap<>();
//        args.put("x-delayed-type", "topic");
//        return new CustomExchange(EXCHANGE_DELAYED, "x-delayed-message", true, false, args);
//    }
//
//    // DLQ exchange (direct)
//    @Bean
//    public DirectExchange dlqExchange() {
//        return new DirectExchange(EXCHANGE_DLX, true, false);
//    }
//
//    private Map<String, Object> queueArgsWithDlq() {
//        Map<String, Object> args = new HashMap<>();
//        args.put("x-dead-letter-exchange", EXCHANGE_DLX);
//        args.put("x-dead-letter-routing-key", RK_DLQ);
//        return args;
//    }
//
//    @Bean
//    public Queue msgImmediateQueue() {
//        return QueueBuilder.durable(QUEUE_MSG_IMMEDIATE).withArguments(queueArgsWithDlq()).build();
//    }
//
//    @Bean
//    public Queue reminderUnclaimedQueue() {
//        return QueueBuilder.durable(QUEUE_REMINDER_UNCLAIMED).withArguments(queueArgsWithDlq()).build();
//    }
//
//    @Bean
//    public Queue reminderOverdueQueue() {
//        return QueueBuilder.durable(QUEUE_REMINDER_OVERDUE).withArguments(queueArgsWithDlq()).build();
//    }
//
//    @Bean
//    public Queue qualityFinalReadyQueue() {
//        return QueueBuilder.durable(QUEUE_QUALITY_FINAL_READY).withArguments(queueArgsWithDlq()).build();
//    }
//
//    @Bean
//    public Queue pmcBatchSubmittedQueue() {
//        return QueueBuilder.durable(QUEUE_PMC_BATCH_SUBMITTED).withArguments(queueArgsWithDlq()).build();
//    }
//
//    @Bean
//    public Queue dlqQueue() {
//        return QueueBuilder.durable(QUEUE_DLQ).build();
//    }
//
//    // Bindings to delayed exchange
//    @Bean
//    public Binding bindMsgImmediateOrderCreated(Queue msgImmediateQueue, Exchange delayedExchange) {
//        return BindingBuilder.bind(msgImmediateQueue).to(delayedExchange).with(RK_ORDER_CREATED).noargs();
//    }
//
//    @Bean
//    public Binding bindMsgImmediateTaskCreated(Queue msgImmediateQueue, Exchange delayedExchange) {
//        return BindingBuilder.bind(msgImmediateQueue).to(delayedExchange).with(RK_TASK_CREATED).noargs();
//    }
//
//    @Bean
//    public Binding bindReminderUnclaimed(Queue reminderUnclaimedQueue, Exchange delayedExchange) {
//        return BindingBuilder.bind(reminderUnclaimedQueue).to(delayedExchange).with(RK_REMINDER_UNCLAIMED).noargs();
//    }
//
//    @Bean
//    public Binding bindReminderOverdue(Queue reminderOverdueQueue, Exchange delayedExchange) {
//        return BindingBuilder.bind(reminderOverdueQueue).to(delayedExchange).with(RK_REMINDER_OVERDUE).noargs();
//    }
//
//    @Bean
//    public Binding bindQualityFinalReady(Queue qualityFinalReadyQueue, Exchange delayedExchange) {
//        return BindingBuilder.bind(qualityFinalReadyQueue).to(delayedExchange).with(RK_QUALITY_FINAL_READY).noargs();
//    }
//
//    @Bean
//    public Binding bindPmcBatchSubmitted(Queue pmcBatchSubmittedQueue, Exchange delayedExchange) {
//        return BindingBuilder.bind(pmcBatchSubmittedQueue).to(delayedExchange).with(RK_PMC_BATCH_SUBMITTED).noargs();
//    }
//
//    // DLQ binding
//    @Bean
//    public Binding bindDlq(Queue dlqQueue, DirectExchange dlqExchange) {
//        return BindingBuilder.bind(dlqQueue).to(dlqExchange).with(RK_DLQ);
//    }
//}